home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SPACE 2
/
SPACE - Library 2 - Volume 1.iso
/
telecom
/
86
/
pascal
/
cursdemo.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1986-12-19
|
10KB
|
392 lines
Program cursordemo(Input,Output);
(* This program was written as a demo of the cursor routines OSS
posted in their BBS. If you are writing Pascal programs with
GEM boxes, you can quit now.
Since the Atari ST screen emulates VT-52, putting the VT-52
escape sequence to the screen via BIOS calls can achieve the
purpose of controlling cursor movement. By using these routine
a programmer can write a TOS program without learing GEM calls
and yet make the program interface acceptable. People may find
out the interface is IBMish and may not like it, especially
for those who own a ST as the first computer in life. However,
if you are porting programs from Turbo Pascal, or write some
quick routines for yourself, these routines are worth to be used.
I add five more procedures to OSS's CURSOR.PAS. They are quite
useful and I don't know why OSS forgot to put them in.
The following program is intent to show how to use these
procedures and how the interface will look like. Only half of
the procedures are used in the demo but the rest of them are
easy to be used.
Leave comments to me via GEnie ( J.CHEN ) or CompuServe
[72327,2434], or just call my BBS (MANIAC) at 207-854-2687
Acknowledge should be made to Tim Harvey who wrote the text
color routines.
Jinfu Chen
*)
Const
cont =' Hit Return to continue ...';
Var
count,row,column : Integer;
selection : Char;
(*$I cursor.pas*)
Procedure delay(delay_time : Long_Integer);
(* a very handy routine to delay time in two seconds multiple,
remember how to do it in BASIC: for I = 1 to 2000? Even to
20000 the ST is still too fast, thanks to the 8 Mhz 68000. *)
Var
first_time : Long_integer;
Begin (* delay *)
first_time := clock;
Repeat
;
Until (clock-first_time) > delay_time
End; (* delay *)
Procedure hold;
Begin (* hold *)
Writeln(cont);
Readln
End; (* hold *)
Function Getrez : Integer;
XBIOS(4) ;
(* check screen resolution *)
Procedure show_off;
Begin (* show_off *)
GotoXy(6,1);
Writeln(' Cursor Routing Demo');
Writeln(' by Jinfu Chen and Tim Harvey');
Writeln(' November 28, 1986');
Writeln(' in Personal Pascal');
Writeln(' Portions of the program are');
Writeln(' copyrighted ',chr(189),' by OSS and CCD ')
End; (* show_off *)
Procedure menu;
(* Here comes the IBMish screen *)
Begin (* menu *)
ClrScr;
GotoXY(3,10);
InverseVideo;
Writeln(' ');
GotoXy(4,10);
Writeln(' Main Menu ');
GotoXy(5,10);
Writeln(' ');
GotoXY(8,8);
InverseVideo;
Write(' 1 ');
NormVideo;
Writeln(' Clear Routing');
GotoXY(10,8);
InverseVideo;
Write(' 2 ');
NormVideo;
Writeln(' Cursor Movement Routing');
GotoXY(12,8);
InverseVideo;
Write(' 3 ');
NormVideo;
Writeln(' Text Color Routing');
GotoXY(14,8);
InverseVideo;
Write(' 0 ');
NormVideo;
Writeln(' Quit' );
GotoXY(18,8);
InverseVideo;
Write(' Enter your choice ==> ');
GotoXY(18,33);
NormVideo;
Read(selection)
End; (* menu *)
Procedure clear;
(* some clear procedures *)
Var
count : Integer;
Begin (* clear *)
ClrScr;
Writeln(' In this section, we learn how to use clear screen rountines');
GotoXy(5,1);
Writeln(' The first one is ClrScr, Clear Screen. This one erases the');
Writeln(' whole screen.');
Delay(2);
ClrScr;
Delay(3);
Writeln(' In this section, we learn how to use clear screen rountines');
GotoXy(5,1);
Writeln(' The next one is ClrEol, Clear from cursor to the');
Writeln(' End of line.');
GotoXy(5,25);
Delay(4);
ClrEol;
Delay(3);
GotoXy(5,1);
Writeln(' We can also use ClrStart to clear from the start of a ');
Writeln(' line to the cursor.');
GotoXy(5,25);
Delay(4);
ClrStart;
Delay(3);
GotoXY(7,1);
Writeln(' ClrLine erases a line and leaves the rest of text intact.');
GotoXY(6,1);
Delay(4);
ClrLine;
Delay(3);
GotoXy(5,1);
Writeln(' The next one is ClrEos, Clear from cursor to the End of line.');
Writeln;
Writeln(' Let us put some garbage in the screen first then erase them.');
For count := 8 To 23 Do
Begin (* for *)
GotoXy(count,1);
Writeln(' GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG');
End; (* for *)
GotoXy(8,1);
Delay(4);
ClrEos;
Delay(3);
GotoXY( 5, 1 );
ClrLine;
Writeln(' You can clear the screen from the top to the cursor by ');
Writeln(' using ClrToCurs.');
GotoXY( 4, 1);
Delay(4);
ClrToCurs;
Delay(3);
End; (* clear *)
Procedure curs_move;
Var
count : Integer;
Begin (* curs_move *)
ClrScr;
Writeln(' This section shows how to use cursor movement routines.');
GotoXy(10,1);
Write('CursUp moves cursor up.');
Delay(1);
For count := 1 To 3 Do
Begin (* for *)
Delay(1);
CursUp;
End; (* for *)
Delay(1);
Write('CursDown moves cursor down.');
For count := 1 To 3 Do
Begin (* for *)
Delay(1);
CursDown;
End; (* for *)
Delay(1);
GotoXy(12,1);
Write('The similar is CursRight.');
For count := 1 To 3 Do
Begin (* for *)
Delay(1);
CursRight;
End; (* for *)
Delay(1);
Write('And CursLeft.');
For count := 1 To 3 Do
Begin (* for *)
Delay(1);
CursLeft;
End; (* for *)
Delay(1);
GotoXy(15,1);
ClrEos;
Writeln(' Now we will try a very useful one, GotoXy(row,column)');
Write(' Which row do you want me to move to (1-24) ? '); readln(row);
Write(' Which column do you want me to move to (1-80) ? '); readln(column);
GotoXy(row,column);
Delay(3);
GotoXY(10,1);
ClrEos;
Writeln(' The next two procedures, SaveCurs and ResCurs, can be');
Writeln(' used to save a position of the cursor and restore it ');
Writeln(' later on.');
Delay(4);
Writeln(' Let us move the cursor to row ten and column one and ');
Writeln(' save it.');
GotoXY(10,1);
SaveCurs;
Delay(3);
Writeln(' Now move it around...');
For count := 1 To 3 Do Begin
CursUp;
Delay(1);
End;
For count := 1 To 3 Do Begin
CursRight;
Delay(1);
End;
For count := 1 To 3 Do Begin
CursDown;
Delay(3);
End;
Writeln(' and restore it back.');
Delay(4);
ResCurs;
Delay(3);
End; (* curs_move *)
Procedure show_text;
VAR CHOICE : CHAR;
PROCEDURE show_MENU;
BEGIN
GOTOXY( 9,1 );
WRITELN(' ');
WRITELN(' Which screen would you like to see? ');
WRITELN(' ');
WRITELN(' 1 Green Screen with Black Text ');
WRITELN(' 2 Black Screen with Red Text ');
WRITELN(' 3 White Screen with Green Text ');
WRITELN(' 4 Black Screen with White Text ');
WRITELN(' 5 Red Screen with Black Text ');
WRITELN(' 6 White Screen with Red Text ');
WRITELN(' 7 I have had enough, thanks! ');
WRITELN(' ');
WRITELN(' Enter Your Selection: ');
WRITELN(' ');
READ(CHOICE);
END; { MENU }
PROCEDURE SET_COLOR;
BEGIN
CASE CHOICE OF
'1' : BEGIN
CLRSCR;
TEXTBACKGROUND (2);
TEXTCOLOR (3)
END;
'2' : BEGIN
CLRSCR;
TEXTBACKGROUND (3);
TEXTCOLOR (1)
END;
'3' : BEGIN
CLRSCR;
TEXTBACKGROUND (0);
TEXTCOLOR (2)
END;
'4' : BEGIN
CLRSCR;
TEXTBACKGROUND(3);
TEXTCOLOR(0);
END;
'5' : BEGIN
CLRSCR;
TEXTBACKGROUND(1);
TEXTCOLOR(3);
END;
'6' : BEGIN
TEXTBACKGROUND(0);
TEXTCOLOR(1);
END;
END { CASE }
END; { SET_COLOR }
BEGIN { MAIN SHOW_TEXT }
CURSOFF;
WHILE CHOICE <> '7' DO
BEGIN
CLRSCR;
show_MENU;
if (choice in ['1','2','3','4','5','6','7']) then
SET_COLOR
END; {WHILE}
NORMVIDEO;
TEXTCOLOR(3);
TEXTBACKGROUND(0);
CURSON;
CLRSCR
END; (* show_text *)
Begin (* main *)
If Getrez = 0 Then Begin
Writeln(' It is better to run this ');
Writeln(' program in medium resolution!');
hold;
End; (* getrez *)
CrtInit; (* not as neccessery as Init_Gem *)
TextColor(3);
TextBackground(2);
CursOff; (* like Hide_Mouse *)
selection := '9';
ClrScr;
Show_off;
Delay(4);
CursOn; (* and like Show_Mouse *)
While selection <> '0' Do
Begin (* while *)
Menu;
If (selection In ['1','2','3','4']) Then (* trap input error*)
Case selection Of
'1' : Clear;
'2' : Curs_move;
'3' : Show_text;
'4' : Menu
End; (* case *)
End; (* while *)
NormVideo; (* don't forget to reset the screen back *)
TextColor(3);
TextBackground(0);
ClrScr;
CrtExit;
End. (* main *)